//
//  ViewController.m
//  03.28-HUDDemo
//
//  Created by student on 16/3/28.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"
#import <MBProgressHUD.h>
@interface ViewController ()<MBProgressHUDDelegate>
{
    MBProgressHUD *hud;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)btn1:(id)sender {
    
    //创建进度条
    hud =[[MBProgressHUD alloc]initWithView:self.view];
    //加入到当前视图
    [self.view addSubview:hud];
    //背景变暗
    hud.dimBackground =YES;
    //文字
    hud.labelText=@"请稍后";
    //显示出来
    [hud showAnimated:YES whileExecutingBlock:^{
        //显示后执行的费时操作
        sleep(3); // =>[NSThread sleepForTimeInterval:3];
    } completionBlock:^{
        //操作完了之后
        [hud removeFromSuperview];
        hud = nil;
    }];
}
- (IBAction)btn2:(id)sender {
    
    hud =[[MBProgressHUD alloc]initWithView:self.view];
    [self.view addSubview:hud];
    hud.dimBackground = YES;
    //hud 的转的样式
    hud.mode = MBProgressHUDModeDeterminateHorizontalBar;
    //文字
    hud.labelText = @"请稍后";
    //代理
    hud.delegate = self;
    //在执行某个任务过程中显示,执行完全隐藏
    [hud showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
    
}

-(void)myTask
{
    
}

- (IBAction)btn3:(id)sender {
}
- (IBAction)btn4:(id)sender {
}
- (IBAction)btn5:(id)sender {
}



@end
